﻿<!DOCTYPE html>

<html>

<head>
    <title>单位信息</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <meta name="description" content="Write an awesome description for your new site here.">

    <link rel="stylesheet" href="/static/css/weui.min.css">
    <link rel="stylesheet" href="/static/css/jquery-weui.css">
    <link rel="stylesheet" href="/static/css/demos.css">
    <link rel="stylesheet" href="/static/css/example.css" />
    <link rel="stylesheet" href="/static/css/iconfont.css">

    <style type="text/css">
        .wy-header {
            height: 38px;
            border-bottom: 1px solid #e1e1e1;
            position: relative;
        }

        .wy-header-icon-menu {
            position: absolute;
            left: 0;
            top: 0;
            width: 40px;
            height: 38px;
        }

        .wy-header-icon-menu span {
            width: 20px;
            height: 20px;
            margin: 8px 0 0 10px;
            background: url(/static/img/list/icon_nav_actionSheet.png) no-repeat;
            background-size: 20px;
            display: block;
        }

        .wy-header-title {
            margin: 0 50px;
            text-align: center;
            height: 38px;
            line-height: 38px;
            font-size: 20px;
            color: #252525;
        }

        .wy-header-icon-back {
            position: absolute;
            right: 0;
            top: 0;
            width: 40px;
            height: 38px;
        }

        .wy-header-icon-back span {
            width: 20px;
            height: 20px;
            margin: 8px 0 0 10px;
            background: url(/static/img/list/icon-back.png) no-repeat;
            background-size: 20px;
            display: block;
        }

        .wxCellGlay {
            background-color: #ccc8c8;
        }

        /*首页图标链接*/

        .wy-iconlist-box {
            background: #fff;
            padding: 0 10px;
        }

        .wy-links-iconlist {
            display: block;
            text-align: center;
            margin: 10px 0;
        }

        .wy-links-iconlist .img {
            margin: 0 23px;
        }

        .wy-links-iconlist img {
            width: 100%;
        }

        .wy-links-iconlist p {
            font-size: 11px;
            color: #454545;
            margin-top: 5px;
        }
    </style>

</head>


<body ontouchstart>

    <div class="weui-toptips weui-toptips_warn js_tooltips">错误提示</div>


    <div class="container" id="container"></div>
    <!-- 容器  -->

    <!-- demo  -->
    <script type="text/html" id="tpl_demo">
<div class="page">

    <div class="page__hd">
        <a href="javascript:home()"><img src="/static/images/icon_footer.png" /></a>
    </div>

    <div class="page__bd page__bd_spacing">
    <a href="javascript:home()"><img src="/static/images/icon_footer.png" /></a>
    </div>

    <div class="page__ft">
        <a href="javascript:home()"><img src="/static/images/icon_footer.png" /></a>
    </div>


</div>
     <script type="text/javascript">
         
      </script>

    </script>

    <script type="text/html" id="tpl_home">
        <div class="page">

            <!--浮动 头部-->
            <div class="page__hd" style="position: fixed; z-index: 99; width: 100%">
                <header class='weui-header fixed-top'>

                    <div class="weui-search-bar" id="searchBar">
                        <!--三个点--> <div class="wy-header-icon-menu" id="gomenu" style="position: absolute; left: 0; top: 4px; width: 35px; height: 38px;"><span></span></div>
                        <form class="weui-search-bar__form" action="#" style="margin-left: 40px">
                            <div class="weui-search-bar__box">
                                <i class="weui-icon-search"></i>
                                <input type="search" class="weui-search-bar__input" id="searchInput" placeholder="搜索" onblur="LostFoucs()">
                                <a href="javascript:" class="weui-icon-clear" id="searchClear"></a>
                            </div>
                            <label class="weui-search-bar__label" id="searchText" style="transform-origin: 0px 0px 0px; opacity: 1; transform: scale(1, 1);">
                                <i class="weui-icon-search"></i>
                                <span>搜索</span>
                            </label>
                        </form>
                        <a href="javascript:var event={};event.keyCode='13'; searchNow(event);" class="weui-search-bar__search-btn" >搜索</a>
                        <a href="javascript:clearSearch();" class="weui-search-bar__cancel-btn" id="searchCancel">取消</a>
                    </div>

                </header>
              

                <!--  上面的浮动快捷菜单 导航子功能 -->
               <div class="weui-panel weui-panel_access" style="margin-top: 0px">
                    <div class="weui-flex wy-iconlist-box" style="padding: 0 10px;">
                        <div class="weui-flex__item">
                            <a href="javascript:g_dwid=null;window.pageManager.go('DanweiEdid');" class="wy-links-iconlist">
                                <div class="img">
                                      <img src="/static/images/add.png"> 
                                </div>
                                <p>录入</p>
                            </a>
                        </div>
                        <div class="weui-flex__item">
                            <a href="javascript:EditCell();" class="wy-links-iconlist">
                                <div class="img">
                                     <img src="/static/images/edit.png"> 
                                </div>
                                <p>修改</p>
                            </a>
                        </div>
                       <!--  <div class="weui-flex__item">
                            <a href="javascript:;" class="wy-links-iconlist" id="scanQRCode">
                                <div class="img">
                                      <img src="/static/images/cust.png"> 
                                </div>
                                <p>扫描</p>
                            </a>
                        </div> -->
                        <div class="weui-flex__item">
                            <a href="javascript:DetailCellurl();" class="wy-links-iconlist">
                                <div class="img">
                                      <img src="/static/images/detail.png"> 
                                </div>
                                <p>详情</p>
                                <div id='yxyid' style ="display:none">YUANGONG2018080002</div>
                            </a>
                        </div>
                        <div class="weui-flex__item">
                            <a href="javascript:changeCell();" class="wy-links-iconlist">
                                <div class="img">
                                    <img src="/static/images/del.png">  
                                </div>
                                <p>交接</p>
                            </a>
                        </div>
                    </div>
                </div>

            </div>


            <div class="weui-panel weui-panel_access" style="margin-top: 10px;">
                <div class="weui-panel__bd">
                    <div class="weui-media-box weui-media-box_small-appmsg">

     
            <!--中间部分-->
            <div class="page__bd page__bd_spacing" style="margin-top: 140px">   

                <div class="weui-panel weui-panel_access" style="margin-top: 10px;">
                <div class="weui-panel__bd">
                  <div class="weui-media-box weui-media-box_small-appmsg">
                    <div class="weui-flex wy-iconlist-box" style="padding: 0 10px;height:33px; border-bottom:1px solid #ddd;">
                      <div class="weui-flex__item" style="text-align:center">
                        <p style="color:gray;font-size:15px;">单位名称</p></div>
                      <div class="weui-flex__item" style="text-align:center">
                        <p style="color:gray;font-size:15px;">总人数</p></div>
                      <div class="weui-flex__item" style="text-align:center">
                        <p style="color:gray;font-size:15px;">总资产</p></div>
                    </div>

                    <div class="weui-cells" id="YxList"></div>
                  </div>
                </div>
              </div>
               <div class="weui-btn-area" id="ftLoad"> 
                    <!-- <a href="javascript:;" class="weui-btn weui-btn_default weui-btn_loading" style="color:#353535"><i class="weui-loading"></i>正在加载...</a> -->
                    <a href="javascript:;" class="weui-btn weui-btn_default" id="ClickLoadMore" style="color:#353535">点击加载更多</a>
                </div>
                <!--底部-->
                <div class="page__ft" > 
                  
                </div>
            </div>
     </div>

  <script type="text/javascript">

                function LostFoucs() {              
                   // $('#searchCancel').trigger('click');
                  //  clearSearch();
                }
                window.YXCallBack =  function (vid,newId,vName,dwrs,zzc) {
                    setTimeout(function () {
                        if(vid)
                        {
                            
                             $('#' + vid).attr("name",vName);
                             $('#div_dwmc'+ vid).html(vName);
                             $('#div_dwrs'+ vid).html(dwrs);
                             $('#div_zzc'+ vid).html(zzc);
                             //$('#' + vid).find('p').html(vName);                       
                             $.toast('修改成功',800);  //调整延时时间
                           
                        }else{
                            $("#YxList").prepend(append_company_html(newId,vName,dwrs,zzc));
                            RegClick() ;
                            $.toast('添加成功',800);
                        }
                    }, 500);
                }

// ×××××××××××××××××××××××交接 开始
                window.YXCallBackaa =  function (vid) {
                    setTimeout(function () {
                        $('#' + vid).remove();
                        $.toast('交接成功',800);
                    }, 500);
                }
// ××××××××××××××××××××××××××交接 结束

                var Cellid = null;

function changeCella() {
    if(Cellid){
    if($('#' + Cellid).length<=0){
        $.toptip('请选择单位', 'error');
        return;
    }
    $.confirm("您确定要删除吗?", "确认删除?", function() {

//删除
$.ajax({
            url: basePath1+"testServlet",

            type: "GET",
            data: {action: 'delete',
                   YGid:Cellid
            },
            crossDomain: true,
            dataType: "json",
            success: function (callBackData, textStatus, jqXHR) {
                console.log(callBackData);
                if(callBackData[0].SUCCESS=="OK"){
                       $("#" + Cellid).remove();
                         $.toptip('删除成功', 'success');
                  }
                  else{ $.toptip('删除失败', 'error');}

             //    $("#YxList").children().remove();
            },error: function (XMLHttpRequest, strError, strObject) { 
               $.alert('网络有问题,请刷新!strError=' + strError + ' strObject=' + strObject);  
          }
        });                          
                   }, function() {
                      //取消操作                       
                   });

                   }   
                   else{ $.toast('请选择单位', "forbidden");}
                }
                function append_companys_html(Num,id) {
                    var htmcode = '<a class="weui-cell weui-cell_access js_item" id="' + id + '" name="'+Num+'"  href="javascript:;">' +
                                    ' <div class="weui-cell__bd">' +
                                         '<p>' + Num + '</p>' +
                                     '</div>' +
                                  '</a>';

                    return htmcode;
                }

                function append_company_html(dwid,dwmc,dwrs,zzc) {
                    var htmcode = '<div class="weui-cell_access weui-flex js_item" id="' + dwid + '" name="' + dwmc + '"  href="javascript:;">'+
                        '<div class="weui-flex__item" >'+'<div class="placeholder" style="text-align:center" id="div_dwmc'+dwid+'">'+dwmc+'</div>'+'</div>'+
                        '<div class="weui-flex__item" >'+'<div class="placeholder" style="text-align:center" id="div_dwrs'+dwid+'">'+dwrs+'</div>'+'</div>'+
                        '<div class="weui-flex__item" >'+'<div class="placeholder" style="text-align:center" id="div_zzc'+dwid+'">'+zzc+'</div>'+'</div>'+
                    '</div>';

                    return htmcode;
                }
function regmoreclick() {
    
    $("#ClickLoadMore").click(function () {
        $('#ClickLoadMore').hide();
        $("#ftLoad").append('<a href="javascript:;" id="idLoading" class="weui-btn weui-btn_default weui-btn_loading" style="color:#353535"><i class="weui-loading"></i>正在加载...</a>');
        var loadmoreCur=$('#YxList').find('.weui-cell_access').length;
        var kwd = $('#searchInput').val();
        var yxyid = $('#yxyid').html()
        kwd = kwd.trim();       
        //加载更多 
        $.ajax({
                    url: basePath1+"company_more",
                    type: "GET",
                    data: {action: 'find',
                        name_find:kwd,
                        offset:loadmoreCur,
                        yxyid:yxyid,
                        pagesize:pagesize
                    },
                    crossDomain: true,
                    dataType: "json",
                    success: function (callBackData, textStatus, jqXHR) {
                        if(callBackData.length==0 ){
                            $("#ftLoad").children().remove();
                            $("#ftLoad").append('<a href="javascript:;" class="weui-btn weui-btn_default"  style="color:#353535">没有更多数据了</a>');
                            return;
                        }
                        else if(callBackData.length<pagesize){
                            $("#ftLoad").children().remove();
                            $("#ftLoad").append('<a href="javascript:;" class="weui-btn weui-btn_default"  style="color:#353535">没有更多数据了</a>');
                                
                                var YxItemLists = $('#YxList').find('.weui-cell_access');
                                var nIndexCur = YxItemLists.length;
                                for (var j = 0; j < callBackData.length; j++, nIndexCur++) {                             
                                    $("#YxList").append(append_company_html(callBackData[j].dwid,callBackData[j].dwmc,callBackData[j].dwrs,callBackData[j].zzc));//点击 加载更多
                                }
                            RegClick() ;
                            return;
                        }
                        else{
                            $("#idLoading").remove();
                            $('#ClickLoadMore').show();
                            var YxItemLists = $('#YxList').find('.weui-cell_access');
                                var nIndexCur = YxItemLists.length;
                                for (var j = 0; j < callBackData.length; j++, nIndexCur++) {
                                    console.log(callBackData[j])                             
                                    $("#YxList").append(append_company_html(callBackData[j].dwid,callBackData[j].dwmc,callBackData[j].dwrs,callBackData[j].zzc));//点击 加载更多
                                }
                            RegClick() ;
                        }
                    },error: function (XMLHttpRequest, strError, strObject) { 
                    $.alert('网络有问题,请刷新!strError=' + strError + ' strObject=' + strObject);  
                }
                });                                                
    });           
}

// *********************************************8交接函数 开始
function changeCell() {
    if(Cellid){
        if($('#' + Cellid).length<=0){
        //$.toptip('请选择要交接的单位', 'error');
        $.toast('请选择要交接的单位', "forbidden");
        return;
        }     
        g_dwid=Cellid;

        window.pageManager.go('DanweiChange');  //DanweiEdid
    }
    else{ $.toast('请选择要交接的单位', "forbidden");}
    }

// ************************************************8交接函数 结束         

function EditCell() {
    if(Cellid){
        if($('#' + Cellid).length<=0){
        //$.toptip('请选择要修改的项目', 'error');
        $.toast('请选择要修改的项目', "forbidden");
        return;
        }     
        g_dwid=Cellid;

        window.pageManager.go('DanweiEdid');
    }
    else{ $.toast('请选择要修改的项目', "forbidden");}
    }

function DetailCell() {
if(Cellid){
    if($('#' + Cellid).length<=0){
    //$.toptip('请选择要修改的项目', 'error');
    $.toast('请选择要修改的项目', "forbidden");
    return;
    }
    g_dwid=Cellid;
    g_YXname=  $('#' +g_dwid).attr("name");
    window.pageManager.go('DanweiEdid');
}
else{ $.toast('请选择要修改的项目', "forbidden");}
}

function DetailCellurl() {
if(Cellid){
    if($('#' + Cellid).length<=0){
    //$.toptip('请选择要修改的项目', 'error');
    $.toast('请选择要修改的项目', "forbidden");
    return;
    }
    url = '/salesman?dwid=' + Cellid
    window.location.href=url   
}
else{ $.toast('请选择要修改的项目', "forbidden");}
}

//监听搜索事件
//document.getElementById('searchInput').addEventListener('keyup', function (e) { if (e.keyCode == 13) { searchNow(); } });

$('#searchInput').bind('keypress', searchNow);
//核心搜索函数

     function searchNow(event) {
                          if (event.keyCode == "13") {
                     //document.activeElement.blur();
                    var kwd = $('#searchInput').val();
                    kwd = kwd.trim();
                    //$.toast('搜索 ' + kwd);
                    $("#YxList").children().remove();
                    //var loadmoreCur=$('#YxList').find('.weui-cell_access').length;
                    console.log('kwd : '+kwd);

//搜索查询
$.ajax({
            url: basePath1+"company_list",

            type: "GET",
            data: {action: 'find',
                   name_find:kwd,
                   offset:0,
                   pagesize:pagesize                   
            },
            crossDomain: true,
            dataType: "json",
            success: function (callBackData, textStatus, jqXHR) {
                console.log("search result : "+callBackData);    
                 if( callBackData.length==pagesize )   {   
                       $("#ftLoad").children().remove();
                       $("#ftLoad").append(' <a href="javascript:;" class="weui-btn weui-btn_default" id="ClickLoadMore" style="color:#353535">点击加载更多</a>');
                       regmoreclick();   
                 }
                 for (var i = 0; i < callBackData.length; i++) {//插入单位信息初始数据
                        $("#YxList").append(append_company_html(callBackData[i].dwid,callBackData[i].dwmc,callBackData[i].dwrs,callBackData[i].zzc));   
                    }
                RegClick() ;

            },error: function (XMLHttpRequest, strError, strObject) { 
               $.alert('网络有问题,请刷新!strError=' + strError + ' strObject=' + strObject);  
          }
        });


          }

     }


//清空
function clearSearch() {
    $('#searchInput').val('');
}

    function RegClick() {
        //  $('.js_item').on('click', function () {
    $(".js_item").click(function () {       //给选中上个色
        if (Cellid == null) {
            Cellid = $(this).attr("id");
            g_dwmc=$(this).attr("dwmc");
            $(this).css('background-color', '#ccc8c8');
            //alert(Cellid);
            g_dwid=Cellid;
        }
        else {
            $("#" + Cellid).css('background-color', '')
            $(this).css('background-color', '#ccc8c8');
            Cellid = $(this).attr("id");
            g_dwmc=$(this).attr("dwmc");
            //alert(Cellid);
            g_dwid=Cellid;
        }

    });
    }
var pagesize=5;

$(function () {
    g_ToastStr = "首页";


    var winH = $(window).height();
    var categorySpace = 10;
    console.log(basePath1);

    //$("#searchCancel").click(clearSearch);

//首次加载
$.ajax({
            url: basePath1+"company_list",

            type: "GET",
            data: {action: 'find',
                   name_find:'',
                   offset:0,
                   pagesize:pagesize
            },
            crossDomain: true,
            dataType: "json",
            success: function (callBackData, textStatus, jqXHR) {
                 for (var i = 0; i < callBackData.length; i++) {//插入单位信息初始数据
                        $("#YxList").append(append_company_html(callBackData[i].dwid,callBackData[i].dwmc,callBackData[i].dwrs,callBackData[i].zzc));   
                    }

                RegClick() ;
                
               // let myData=callBackData.data;
               // ipInfoObj.value=myData.country+""+myData.province+""+myData.city;
               // console.log(myData);
               if(callBackData.length<pagesize){
                       $("#ftLoad").children().remove();
                       $("#ftLoad").append('<a href="javascript:;" class="weui-btn weui-btn_default"  style="color:#353535">没有更多数据了</a>');                
                }
            },
            // error: function (XMLHttpRequest, strError, strObject,) { 
            //    $.alert('网络有问题,请刷新!strError=' + strError + ' strObject=' + strObject);  
            // }
            error:function(data,type, err){
	         console.log(data);
             console.log("ajax错误类型："+type);
	         console.log(err);
            }
        });


                  /*  for (var i = 0; i < 20; i++) {//插入营销员初始数据
                        $("#YxList").append(append_company_html(i));
                                    error:function(data,type, err){
	         console.log("ajax错误类型："+type);
	         console.log(err);
                       
                    }*/

                    //  $('#ClickLoadMore').on('click', function () {


            regmoreclick();             


            $("#gomenu").click(function () {    //弹出上拉菜单
                $.actions({
                    title: "选择操作",
                    onClose: function () {
                        console.log("close");
                    },
                    actions: [
                        {
                            text: "添加",
                            className: "color-primary",
                            onClick: function () {
                                $.alert("发布成功");
                                //window.pageManager.go('DanweiEdid');
                            }
                        },
                        {
                            text: "编辑",
                            className: "color-warning",
                            onClick: function () {
                                $.alert("你选择了“编辑”");
                                // window.pageManager.go('DanweiEdid');
                            }
                        },
                        {
                            text: "删除",
                            className: 'color-danger',
                            onClick: function () {
                                $.alert("你选择了“删除”");
                                // window.pageManager.go('demo');    //导航到子页面demo
                            }
                        }
                    ]
                });

            });

                });
            </script>
    </script>

    <!--编辑内-->
    <script type="text/html" id="tpl_DanweiEdid">

        <div class="page">
            <div class="page__hd">
                <header class="wy-header">   
                     <div class="wy-header-title" id ="idTitle">单位修改</div>
                    <div class="wy-header-icon-back" id="goback1"><span></span></div> 
                 
                </header>
            </div>

            <div class="page__bd page__bd_spacing" style="margin-top: 0px">

                <div class="weui-cells weui-cells_form">

                 <div class="weui-cell" style="background-color:#ebedf0">
                        <div class="weui-cell__hd">
                            <label class="weui-label">单位ID</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text" name="dwid"  placeholder="请输入单位ID(必填)" value="" >
                        </div>
                    </div>


                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <label class="weui-label">单位名称</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text" name="dwmc" placeholder="请输入单位名称(必填)" value="">
                        </div>
                    </div>

                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <label class="weui-label">单位人数</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="tel" name="dwrs" placeholder="请输入单位人数(必填)">
                        </div>
                    </div>

                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <label class="weui-label">开办邮益宝人数</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text" name="kbyybrs" placeholder="请输入开办邮益宝人数(必填)">
                        </div>
                    </div>

                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <label class="weui-label">总资产</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text" name="zzc" placeholder="  请输入总资产">
                        </div>
                    </div>

                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <label class="weui-label">归属部门</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text" name="gsbm"  placeholder="  请输入归属部门(选填)">
                        </div>
                    </div>

                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <label class="weui-label">归属网点</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text" name="gswd"  placeholder="  请输入归属网点(选填)">
                        </div>
                    </div>

                </div>


                <div class="weui-btn-area">
                    <a class="weui-btn weui-btn_primary" href="javascript:;" id="showTooltips">确定</a>
                    <a href="javascript:history.back();" class="weui-btn weui-btn_default">返回</a>
                </div>

            </div>
            <div class="page__ft">
               
            </div>
        </div>
        <script type="text/javascript">

            

            $(function () {
                //$.toast(g_ToastStr);
                if(g_dwid!=null)
                 {
                    $("input[name = 'dwid']").val( g_dwid );
                    $.ajax({ //
                                url: basePath1+"company_serch",

                                type: "GET",
                                data: {action: 'company_serch',
                                        dwid:g_dwid                                      
                                },
                                crossDomain: true,
                                dataType: "json",
                                success: function (callBackData, textStatus, jqXHR) {
                                    console.log(callBackData);
                                    $("input[name = 'dwrs']").val( callBackData[0].dwrs );
                                    $("input[name = 'dwmc']").val( callBackData[0].dwmc);
                                    $("input[name = 'zzc']").val( callBackData[0].zzc);
                                    $("input[name = 'kbyybrs']").val( callBackData[0].kbyybrs);
                                    $("input[name = 'gsbm']").val( callBackData[0].gsbm);
                                    $("input[name = 'gswd']").val( callBackData[0].gswd);
                                                
                                    
                                },error: function (XMLHttpRequest, strError, strObject) { 
                                    $.alert('网络有问题,请刷新!strError=' + strError + ' strObject=' + strObject);  
                                }
                    }); // ajax

                 }
                 else{
                   $("#idTitle").html('新增单位');
                }
                $("#goback1").click(function () {
                    history.back();
                });
                
                $("#showTooltips").click(function () {

                    var data = {};
                    data.dwid = $("input[name = 'dwid']").val();
                    data.dwmc = $("input[name = 'dwmc']").val();
                    data.dwrs = $("input[name = 'dwrs']").val();
                    data.zzc = $("input[name = 'zzc']").val();
                    data.kbyybrs = $("input[name = 'kbyybrs']").val();
                    data.gsbm = $("input[name = 'gsbm']").val();
                    data.gswd = $("input[name = 'gswd']").val();
                    console.log('uuuuuuuuuuuuu')
                    console.log(data.dwmc)

                    if (data.dwmc.length < 2) {
                        $.alert('单位长度太短');
                        return;
                    }

                    $.ajax({ //新增或修改
                                url: basePath1+"company_inser",

                                type: "GET",
                                data: {action: 'company_inser',
                                        dwid:data.dwid,
                                        dwmc:data.dwmc,
                                        dwrs:data.dwrs,
                                        zzc:data.zzc,
                                        kbyybrs:data.kbyybrs,
                                        gsbm:data.gsbm,
                                        gswd:data.gswd
                                },
                                crossDomain: true,
                                //dataType: "json",
                                success: function (callBackData, textStatus, jqXHR) {
                                    console.log(callBackData);
                                
                                if(callBackData.length>0){
                                    //console.log(data.dwmc);
                                    history.back();
                                    if(window.YXCallBack){ window.YXCallBack(g_dwid,callBackData,data.dwmc,data.dwrs,data.zzc); }
                                }else{
                                    $.toptip('返回为空‘', 'error');
                                }
                                
                                },error: function (XMLHttpRequest, strError, strObject) { 
                                $.alert('网络有问题,请刷新!strError=' + strError + ' strObject=' + strObject);  
                                }
                    }); // ajax
                   
                });// click

            });// func
        
        </script>
    </script>

    <!--*************************8 交接编辑 开始 ×××××××××××××××××××××××× -->
    <script type="text/html" id="tpl_DanweiChange">

        <div class="page">
            <div class="page__hd">
                <header class="wy-header">   
                     <div class="wy-header-title" id ="idTitle">单位交接</div>
                    <div class="wy-header-icon-back" id="goback1"><span></span></div> 
                 
                </header>
            </div>

            <div class="page__bd page__bd_spacing" style="margin-top: 0px">

                <div class="weui-cells weui-cells_form">

                    <div class="weui-cell" style="background-color:#ebedf0">
                            <div class="weui-cell__hd">
                                <label class="weui-label">单位ID</label>
                            </div>
                            <div class="weui-cell__bd">
                                <input class="weui-input" type="text" name="dwid" disabled="disabled" value="" >
                            </div>
                    </div>


                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <label class="weui-label">单位名称</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text" name="dwmc" disabled="disabled" value="">
                        </div>
                    </div>




                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <label class="weui-label">营销员ID</label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text" name="yxyid" required="required" placeholder="请输入营销员ID(必填)">
                        </div>
                    </div>

                </div>


                <div class="weui-btn-area">
                    <a class="weui-btn weui-btn_primary" href="javascript:;" id="showTooltipsaa">确定</a>
                    <a href="javascript:history.back();" class="weui-btn weui-btn_default">返回</a>
                </div>

            </div>
            <div class="page__ft">
               
            </div>
        </div>
        <script type="text/javascript">

            $(function () {
                //$.toast(g_ToastStr);

                $("input[name = 'dwid']").val( g_dwid );
                $.ajax({ //
                            url: basePath1+"company_serch",

                            type: "GET",
                            data: {action: 'company_serch',
                                    dwid:g_dwid                                      
                            },
                            crossDomain: true,
                            dataType: "json",
                            success: function (callBackData, textStatus, jqXHR) {
                                console.log(callBackData);
                                $("input[name = 'yxyid']").val( callBackData[0].yxyid );
                                $("input[name = 'dwmc']").val( callBackData[0].dwmc);
                                         
                                
                            },error: function (XMLHttpRequest, strError, strObject) { 
                                $.alert('网络有问题,请刷新!strError=' + strError + ' strObject=' + strObject);  
                            }
                }); // ajax

                
                $("#goback1").click(function () {
                    history.back();
                });
                
                $("#showTooltipsaa").click(function () {

                    var data = {};
                    data.dwid = $("input[name = 'dwid']").val();
                    data.dwmc = $("input[name = 'dwmc']").val();
                    data.yxyid = $("input[name = 'yxyid']").val();

                    if (data.yxyid.length == 0) {
                        $.alert('营销员ID 不能为空');
                        return;
                    }

                    console.log('11111111111111111')
                    console.log(data.yxyid)
                    console.log(data.dwmc)

                    $.ajax({ //交接 修改
                                url: basePath1+"company_change_yxyid",

                                type: "GET",
                                data: {action: 'company_change_yxyid',
                                        dwid:data.dwid,
                                        //dwmc:data.dwmc,
                                        yxyid:data.yxyid
                                },
                                crossDomain: true,
                                //dataType: "json",
                                success: function (callBackData, textStatus, jqXHR) {
                                    console.log('222222222222222222');
                                    console.log(callBackData);
                                
                                if(callBackData=='OK'){
                                    //console.log(data.dwmc);
                                    history.back();
                                    if(window.YXCallBackaa){ window.YXCallBackaa(g_dwid); }
                                }else{
                                    $.toptip('返回为空‘', 'error');
                                }
                                
                                },error: function (XMLHttpRequest, strError, strObject) { 
                                $.alert('网络有问题,请刷新!strError=' + strError + ' strObject=' + strObject);  
                                }
                    }); // ajax
                   
                });// click

            });// func
        
        </script>
    </script>
    <!--*************************8 交接编辑 结束 ×××××××××××××××××××××××× -->
    


    <!-- <script src="../js/jquery-2.1.4.js"></script> -->
    <script src="/static/js/zepto.min.js"></script>
    <script src="/static/js/jquery-weui.js"></script>
    <script src="/static/js/example.js"></script>
    <!-- <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> -->

    <!--  <script src="../js/webuploader-0.1.5/webuploader.min.js"></script> -->

    <script src="/static/js/zeptoUpload.js"></script>

    <script type="text/javascript">

        var g_ToastStr = "操作成功";
        var basePath1 = "http://0.0.0.0:5000/";  //当前url路径
        var g_YXId = null;//


        var g_dwid = null;
        var g_dwmc = null;
        var g_dwrs = null;
        var g_zzc = null;
        var g_kbyybrs = null;
        var g_gsbm = null;
        var g_gswd = null;

    </script>

</body>

</html>
